<template>
  <el-select
    :value="value"
    :clearable="clearable "
    :filterable="filterable "
    placeholder="品牌"
    @input="handleInput"
    @focus="handleFocus"
    @blur="handleBlur"
    @change="handleChange"
  >
    <el-option
      v-for="item in list"
      :key="item.BRAND_ID"
      :label="item.BRAND_NAME"
      :value="item.BRAND_ID"
    />
  </el-select>
</template>

<script>
import { getDealerBrand } from '@/api/cars/dcs/brand'
import selectComponents from './selectComponents'

export default {
  name: 'Dealerbrandselect',
  mixins: [selectComponents],
  data() {
    return {
      list: [],
      dealerbrandrelation: {
        BRAND_CODE: '',
        BRAND_NAME: ''
      }
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    loadData() {
      getDealerBrand().then(res => {
        this.list = res
      })
    },
    // 下拉框选中
    handleChange(data) {
      this.dealerbrandrelation = {
        BRAND_CODE: data.BRAND_CODE,
        BRAND_ID: data.BRAND_ID,
        BRAND_NAME: data.BRAND_NAME
      }
      this.form.BRAND_CODE = this.dealerbrandrelation.BRAND_CODE
      this.form.BRAND_NAME = this.dealerbrandrelation.BRAND_NAME
    }
  }
}
</script>
